import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:text_gradiate/text_gradiate.dart';
import 'package:vape_xe/services/services.dart';
import 'package:vape_xe/utils/utils.dart';
import 'package:vape_xe/values/values.dart';

import 'logic.dart';

class WithdrawDetailsView extends GetView<WithdrawDetailsController> {
  const WithdrawDetailsView({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        leading: IconButton(
          icon: const Icon(Icons.arrow_back_ios_new_rounded),
          onPressed: () => Get.back(),
        ),
      ),
      body: Obx(
        () => controller.withdrawDetails.isEmpty
            ? const Center(child: CircularProgressIndicator())
            : SingleChildScrollView(
                child: Padding(
                  padding: EdgeInsets.only(left: 39.w),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      20.hGap,
                      TextGradiate(
                        text: SizedBox(
                          width: 300.w,
                          child: Text(
                            controller.getStatusString(),
                            style: TextStyle(fontSize: 32.sp, fontFamily: 'Montserrat', fontWeight: FontWeight.bold),
                          ),
                        ),
                        colors: controller.withdrawDetails['state'] == 2
                            ? const [Color(0xffF5B946), Color(0xffF58546)]
                            : controller.withdrawDetails['state'] == 3
                                ? const [Color(0xffE71B1B), Color(0xffE71B1B)]
                                : [AppColors.secondaryText, AppColors.secondaryText],
                        gradientType: GradientType.linear,
                        begin: Alignment.centerLeft,
                        end: Alignment.centerRight,
                        tileMode: TileMode.clamp,
                      ),
                      32.hGap,
                      if (controller.withdrawDetails['realMoney'] != null &&
                          controller.withdrawDetails['realMoney'].isNotEmpty) ...[
                        Text(
                          'Amount of money received'.tr.toUpperCase(),
                          style: TextStyle(
                            fontSize: 22.sp,
                            fontFamily: 'Montserrat',
                            fontWeight: FontWeight.bold,
                            color: AppColors.thirdText,
                          ),
                        ),
                        9.hGap,
                        Text(
                          '${ConfigStore.to.currency}${controller.withdrawDetails['realMoney']}',
                          style: const TextStyle(fontFamily: 'Montserrat'),
                        ),
                        16.hGap,
                        Divider(height: 1.h, color: Colors.white10),
                        16.hGap,
                      ],
                      Text(
                        'Withdraw amount'.tr.toUpperCase(),
                        style: TextStyle(
                          fontSize: 22.sp,
                          fontFamily: 'Montserrat',
                          fontWeight: FontWeight.bold,
                          color: AppColors.thirdText,
                        ),
                      ),
                      9.hGap,
                      Text(
                        '${ConfigStore.to.currency}${controller.withdrawDetails['money']}',
                        style: const TextStyle(fontFamily: 'Montserrat'),
                      ),
                      16.hGap,
                      Divider(height: 1.h, color: Colors.white10),
                      16.hGap,
                      Text(
                        'Address'.tr.toUpperCase(),
                        style: TextStyle(
                          fontSize: 22.sp,
                          fontFamily: 'Montserrat',
                          fontWeight: FontWeight.bold,
                          color: AppColors.thirdText,
                        ),
                      ),
                      9.hGap,
                      Text(
                        controller.withdrawDetails['account'],
                        style: const TextStyle(fontFamily: 'Montserrat'),
                      ),
                      16.hGap,
                      Divider(height: 1.h, color: Colors.white10),
                      16.hGap,
                      Text(
                        'Account type'.tr.toUpperCase(),
                        style: TextStyle(
                          fontSize: 22.sp,
                          fontFamily: 'Montserrat',
                          fontWeight: FontWeight.bold,
                          color: AppColors.thirdText,
                        ),
                      ),
                      9.hGap,
                      Text(
                        controller.withdrawDetails['accountType'] == 3 ? 'DuitNow' : 'USDT',
                        style: const TextStyle(fontFamily: 'Montserrat'),
                      ),
                      16.hGap,
                      Divider(height: 1.h, color: Colors.white10),
                      16.hGap,
                      if (controller.withdrawDetails['transDate'] != null &&
                          controller.withdrawDetails['transDate'].isNotEmpty) ...[
                        Text(
                          'Time of transfer'.tr.toUpperCase(),
                          style: TextStyle(
                            fontSize: 22.sp,
                            fontFamily: 'Montserrat',
                            fontWeight: FontWeight.bold,
                            color: AppColors.thirdText,
                          ),
                        ),
                        9.hGap,
                        Text(
                          controller.withdrawDetails['transDate'],
                          style: const TextStyle(fontFamily: 'Montserrat'),
                        ),
                        16.hGap,
                        Divider(height: 1.h, color: Colors.white10),
                        16.hGap,
                      ],
                      Text(
                        'Credit time'.tr.toUpperCase(),
                        style: TextStyle(
                          fontSize: 22.sp,
                          fontFamily: 'Montserrat',
                          fontWeight: FontWeight.bold,
                          color: AppColors.thirdText,
                        ),
                      ),
                      9.hGap,
                      Text(
                        controller.withdrawDetails['createTime'],
                        style: const TextStyle(fontFamily: 'Montserrat'),
                      ),
                      16.hGap,
                      Divider(height: 1.h, color: Colors.white10),
                      16.hGap,
                      if (controller.withdrawDetails['failReason'] != null &&
                          controller.withdrawDetails['failReason'].isNotEmpty) ...[
                        Text(
                          'Reasons for failure'.tr.toUpperCase(),
                          style: TextStyle(
                            fontSize: 22.sp,
                            fontFamily: 'Montserrat',
                            fontWeight: FontWeight.bold,
                            color: AppColors.thirdText,
                          ),
                        ),
                        9.hGap,
                        Text(
                          controller.withdrawDetails['failReason'],
                          style: const TextStyle(fontFamily: 'Montserrat'),
                        ),
                        16.hGap,
                        Divider(height: 1.h, color: Colors.white10),
                        16.hGap,
                      ],
                    ],
                  ),
                ),
              ),
      ),
    );
  }
}
